library(tidyverse)
library(org.Hs.eg.db)
library(clusterProfiler)
list <- read.table("list", sep = "\t")
genelist <- bitr(list$V1, fromType="SYMBOL",
                 toType="ENTREZID", OrgDb='org.Hs.eg.db')

#GO
go <- enrichGO(gene = genelist$ENTREZID,
               OrgDb = org.Hs.eg.db, 
               ont = "all",
               pAdjustMethod = "BH",
               minGSSize = 1,
               pvalueCutoff =1, 
               qvalueCutoff =1,
               readable = TRUE)

go_res <- go@result
write.table(go_res,file="go_all.txt",sep = "\t",row.names = T,col.names = NA,quote = F)

#KEGG
kegg <- enrichKEGG(gene         = genelist$ENTREZID,
                   organism     = 'hsa',
                   pvalueCutoff = 0.1,
                   qvalueCutoff =0.1)
kegg_res <- kegg@result
write.table(kegg_res,file="kegg_all.txt",sep = "\t",row.names = T,col.names = NA,quote = F)
